//
//  TYHomeFunctionScollCell.m
//  爱鲜蜂
//
//  Created by 李田 on 16/11/19.
//  Copyright © 2016年 tianyao. All rights reserved.
//

#import "LBHomeFunctionScollCell.h"
#import "TYScrollFlowLayout.h"
#import "LBHomeFunction_ScrollCell.h"

@interface LBHomeFunctionScollCell ()<UICollectionViewDelegate, UICollectionViewDataSource>

//collectionV
@property(nonatomic, weak)UICollectionView *collectionV;

@end

static NSString *scrollCellID = @"scrollCell_ID";
@implementation LBHomeFunctionScollCell

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}
#pragma mark - 2.0 数据源加载
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 6;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    LBHomeFunction_ScrollCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:scrollCellID forIndexPath:indexPath];
    
    cell.backgroundColor = [UIColor cz_randomColor];
    return cell;
}

#pragma mark - 1.0 搭建界面
- (void)setupUI{
    
    self.backgroundColor = [UIColor cz_colorWithHex:0xf5f5f9];
    
    TYScrollFlowLayout *flowLayout = [[TYScrollFlowLayout alloc] init];
    
    UICollectionView *collectionV = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
    
    [self.contentView addSubview:collectionV];
    
    collectionV.backgroundColor = [UIColor whiteColor];
    
    //    MARK: 关联
    self.collectionV = collectionV;
    //    MARK: 代理
    self.collectionV.delegate = self;
    self.collectionV.dataSource = self;
    //    MARK: 注册
    [collectionV registerClass:[LBHomeFunction_ScrollCell class] forCellWithReuseIdentifier:scrollCellID];
    //    MARK: 取消导航条
    collectionV.showsHorizontalScrollIndicator = NO;
    
    //    MARK: 布局
    [collectionV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.contentView);
    }];
    
}


@end
